/*
 * Copyright (c) 2007 IJO Technologies Ltd.
 * www.ijotechnologies.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * IJO Technologies ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with IJO Technologies.
 */

package com.iye.puretennis.domain;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author Daiyu Chen
 */
public class ChatMessage {
    private String guid;

    private String senderGuid;

    private String message;

    private String datetime;

    public ChatMessage(String guid, String senderGuid, String message, String datetime) {
        this.guid = guid;
        this.senderGuid = senderGuid;
        this.message = message;
        this.datetime = datetime;
    }

    public String getGuid() {
        return guid;
    }

    public String getSenderGuid() {
        return senderGuid;
    }

    public String getMessage() {
        return message;
    }

    public String getDatetime() {
        return datetime;
    }

    public boolean senderIsMe(String guid) {
        return senderGuid.equals(guid);
    }

    public String getJSONString() {
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("guid", guid);
            jsonObject.put("sender", senderGuid);
            jsonObject.put("message", message);
            jsonObject.put("time", datetime);
            return jsonObject.toString();

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
}
